<#include "/include/layout.ftl" />

<@layout "用户管理">

    <div class="layui-container fly-marginTop fly-user-main">

        <@userCenterLeft index=6></@userCenterLeft>

        <div class="site-tree-mobile layui-hide">
            <i class="layui-icon">&#xe602;</i>
        </div>
        <div class="site-mobile-shade"></div>

        <div class="site-tree-mobile layui-hide">
            <i class="layui-icon">&#xe602;</i>
        </div>
        <div class="site-mobile-shade"></div>


        <div class="fly-panel fly-panel-user" pad20>
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title" id="LAY_mine">
                    <li class="layui-this" lay-id="info">我的资料</li>
                    <li lay-id="avatar">头像</li>
                </ul>
                <div class="layui-tab-content" style="padding: 20px 0;">
                    <div class="layui-form layui-form-pane layui-tab-item layui-show">
                        <table class="layui-table">
                            <colgroup>
                                <col width="80">
                                <col width="150">
                                <col width="90">
                                <col width="75">
                                <col>
                                <col width="160">
                                <col width="120">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>头像</th>
                                <th>用户名</th>
                                <th>社区认证</th>
                                <th>性别</th>
                                <th>城市</th>
                                <th>邮箱</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#list pageData.records as user>
                                <tr>
                                    <td><img alt="头像" width="50" height="50" src="${user.avatar}"></td>
                                    <td>${user.username}</td>
                                    <td>${user.authName}</td>
                                    <#if user.gender == '0'>
                                        <td>男</td>
                                    </#if>
                                    <#if user.gender == '1'>
                                        <td>女</td>
                                    </#if>
                                    <#if user.gender == '-1'>
                                        <td>保密</td>
                                    </#if>
                                    <td>${user.city}</td>
                                    <td>${user.email}</td>
                                    <td style="padding: 9px 0 9px 10px">
                                        <button type="button" onclick="editOrSave('edit', '${user.id}')"
                                                class="layui-btn layui-btn-sm  layui-btn-radius layui-btn-warm">
                                            修改
                                        </button>
                                        <#if user.status gte -1>
                                            <button type="button" onclick="updateUserStatus('${user.id}',-2)"
                                                    class="layui-btn layui-btn-sm  layui-btn-radius layui-btn-danger"
                                                    style="margin-left: 5px">
                                                封禁
                                            </button>
                                        </#if>
                                        <#if user.status lt -1>
                                            <button type="button" onclick="updateUserStatus('${user.id}',0)"
                                                    class="layui-btn layui-btn-sm  layui-btn-radius layui-btn-danger"
                                                    style="margin-left: 5px">
                                                解封
                                            </button>
                                        </#if>
                                    </td>
                                </tr>
                            </#list>
                            </tbody>
                        </table>
                        <@paging pageData></@paging>
                    </div>

                    <div class="layui-form layui-form-pane layui-tab-item">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <#include "/admin/userForm.ftl" />

    <script>
      layui.cache.page = 'user';

      function updateUserStatus(userId, status) {
        $.post('/admin/user/status/' + userId + "/" + status, function (res) {
          layer.msg(res.msg)
          if (res.status === 0) {
            location.reload()
          }
        })
      }
    </script>
</@layout>
